import { shipType } from "/@/config/shipType.js"
import { getDictLabel } from "/@/utils/methods"
import { formatTime, dateFormat } from '/@/utils/date.js';

export const columnList = {
  info: {
    title: '关注记录',
    list: [
      {
        name: '策略',
        prop: 'policyName',
      },
      {
        name: '区域',
        prop: 'areaName',
      },
      {
        name: '触发时间',
        prop: 'startTime',
        format: (row) => {
          if (!row.startTime) {
            return '';
          } else {
            return dateFormat(row.startTime);
          }
        },
      },
      {
        name: '结束时间',
        prop: 'endTime',
      },
      {
        name: '时长',
        prop: 'timeLength',
        format: (row) => {
          if (!row.endTime) {
            return '';
          } else {
            const time = Math.floor((+new Date(row.endTime) - +new Date(row.startTime)) / 1000);
            return formatTime(time);
          }
        },
      },
      {
        name: '',
        prop: 'alarmMessage',
      },
    ],
  },
  radar: {
    title: '雷达目标',
    list: [
      {
        name: '编号',
        prop: 'targetSn',
      },
      {
        name: '名称',
        prop: 'vesselName'
      },
      {
        name: '发现雷达',
        prop: 'radarKey',
        format: (row) => {
          return row.radarKey || "虚拟雷达"
        },
      },
      {
        name: '最小速度',
        prop: 'minSpeed',
        format: (row) => {
          if (!row.minSpeed) {
            return '';
          } else {
            // return (row.minSpeed * 0.5144).toFixed(2) + ' m/s'
            return row.minSpeed.toFixed(2) + "节"
          }
        },
      },
      {
        name: '平均速度',
        prop: 'averageSpeed',
        format: (row) => {
          if (!row.averageSpeed) {
            return '';
          } else {
            // return (row.averageSpeed * 0.5144).toFixed(2) + ' m/s'
            return row.averageSpeed.toFixed(2) + "节"
          }
        },
      },
      {
        name: '最大速度',
        prop: 'maxSpeed',
        format: (row) => {
          if (!row.maxSpeed) {
            return '';
          } else {
            // return (row.maxSpeed * 0.5144).toFixed(2) + ' m/s'
            return row.maxSpeed.toFixed(2) + "节"
          }
        },
      },
      {
        name: '平均测高',
        prop: 'avgHeight',
        util: "米"
      },
      {
        name: '发现时间',
        prop: 'detectedTime',
      },
      {
        name: '消失时间',
        prop: 'lostTime',
      },
      {
        name: '生存时间',
        prop: 'timeLength',
        format: (row) => {
          if (!row.lostTime) {
            return '';
          } else {
            const time = Math.floor((+new Date(row.lostTime) - +new Date(row.detectedTime)) / 1000);
            return formatTime(time);
          }
        },
      },
      {
        name: '点迹数',
        prop: 'radarCount',
      },
    ],
  },
  ais: {
    title: 'AIS目标',
    list: [
      {
        name: 'MMSI',
        prop: 'mmsi',
      },
      {
        name: '船名',
        prop: 'vesselName',
      },
      {
        name: '船舶类型',
        prop: 'vesselType',
        format: (row) => {
          return getDictLabel(row.vesselType, shipType)
        }
      },
      {
        name: '呼号',
        prop: 'callSign',
      },
      {
        name: '船长',
        prop: 'length',
        format: (row) => {
          const length = row.toBow + row.toStern
          return length ? length + ' 米' : ''
        }
      },
      {
        name: '船宽',
        prop: 'chuankuan',
        format: (row) => {
          const length = row.toStarboard + row.toPort
          return length ? length + ' 米' : ''
        }
      },
      {
        name: '吃水',
        prop: 'draft',
        format: (row) => {
          return row.draft ? row.draft + ' 米' : ''
        }
      },
      {
        name: '更新时间',
        prop: 'endTime',
        format: (row) => {
          return dateFormat(new Date(+new Date(row.endTime) + Math.random() * 10000))
        }
      },
    ],
  },
}

export const alarmInfo = {
  "policyName": "郑应上游前置关注",
  "areaName": "郑应上游前置",
  "startTime": "2024-09-09 13:39:02.937",
  "endTime": "2024-09-09 13:40.09.445",
  "shichaang": "00:01:06.6080000",
  "bianhao": "3580788",
  "mingcheng": "WANLPENG 568",
  "faxianleida": "AIS虚拟",
  "zuixiaosudu": "1.90m/s",
  "pingjunshijian": "2.68m/s",
  "zuidasudu": "8.80m/s",
  "chang": "0.00m",
  "kuan": "0.00m ",
  "gao": "6.65m",
  "faxianshijian": "2024-09-09 13:39:02.363",
  "xiaoshishijian": "2024-09-09 13:40.09.445",
  "shengcunshijian": "00:01:06.6080000",
  "dianjsihu": "241",
  "mmsi": "413817386",
  "chuanming": "WANLPENG 568",
  "chuanboleixing": "Cargo",
  "huhao": "",
  "chuanchang": "50",
  "chuankuan": "11",
  "chishui": "2.8",
  "gengxinshijian": "9/9/2024 1:51:25 PM",
}

export const tableOptions = [
  {
    name: '摄像头',
    prop: 'cameraName',
    width: 200,
    proportion: () => {
      return 200 / 750 * 100
    }
  },
  {
    name: '开始',
    prop: 'startTime',
    width: 135,
    proportion: () => {
      return 135 / 750 * 100
    }
  },
  {
    name: '结束',
    prop: 'endTime',
    width: 135,
    proportion: () => {
      return 135 / 750 * 100
    }
  },
  {
    name: '回放地址',
    prop: 'playbackStreamUrl',
    width: 200,
    proportion: () => {
      return 200 / 750 * 100
    }
  },
  {
    name: '操作',
    prop: 'opera',
    type: 'opera',
    width: 80,
    proportion: () => {
      return 80 / 750 * 100
    }
  },
]